package ru.st.selenium;

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import ru.st.selenium.model.Film;
import ru.st.selenium.model.User;
import ru.st.selenium.pages.PageManager;

public class DeleteFilm extends ru.st.selenium.pages.TestBase {
	
	@BeforeMethod
	public void login() throws Exception {
		if (!app.getUserHelper().isLoggedIn()){
			User user = new User().setLogin("admin").setPassword("admin");
			app.getUserHelper().loginAs(user);
		}
		AddFilm();
		app.getNavigationHelper().openMainPage();
	}
	public void AddFilm() throws Exception {
		Film film = new Film().setTitle("Lord of the Rings - 2 Towers")
				.setYear("2002");
		app.getFilmHelper().create(film);
		
		final PageManager pageManager = app.getFilmHelper().getPageManager();
		if (!pageManager.filmInfoPage.isFilmAdded()) {
			throw new RuntimeException();
		}
	}

	@Test
	public void deleteFilm() throws Exception {
		app.getFilmHelper().delete(null);
		
		
	}
}
